package day07;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
       /* System.out.println("请输入机票的原价");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int num = scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();

        double  finalPrice= calAirPrice(price,num,type);
        if (finalPrice!=-1) {
            System.out.println("最终的价格为：" + finalPrice);
        }

    }
    public static double calAirPrice(double price, int num, int type){
        double finalPrice=0.0;
        if(num<1||num>12){
            System.out.println("输入月份错误");
            return -1;
        }
        if(type<1||type>3){
            System.out.println("输入舱位错误");
            return -1;
        }
        if(num<=10&&num>=5){
           switch (type){
               case 1:
                   finalPrice=price*0.9;
                   break;
               case 2:
                   finalPrice=price*0.8;
                   break;
               case 3:
                   finalPrice=price*0.7;
                   break;
           }
        }else{
            switch (type){
                case 1:
                    finalPrice=price*0.8;
                    break;
                case 2:
                    finalPrice=price*0.7;
                    break;
                case 3:
                    finalPrice=price*0.6;
                    break;
            }


        }

        return finalPrice;*/


       /* System.out.println("请输入机票原价");
        double price= scan.nextDouble();
        System.out.println("请输入月份");
        int month= scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int num= scan.nextInt();
        double finalPrice=calAirPrice(price,month,num);
        if(finalPrice!=-1){
        System.out.println("最终机票价格为："+finalPrice);
    }


    }
    public static double calAirPrice(double price, int month,int num){
        double finalPrice=0.0;
        if (month>12&&month<1){
            System.out.println("输入错误");
            return -1;
        }
        if (num<1&&num>3){
            System.out.println("输入错误");
            return -1;
        }
        if(month<=10&&month>=5){
            switch (num){
                case 1:
                  finalPrice= price*0.7;
                   break;
                case 2:
                   finalPrice= price*0.8;
                    break;
                case 3:
                   finalPrice= price*0.9;
                    break;
            }

        }else{
            switch (num){
                case 1:
                   finalPrice= price*0.8;
                    break;
                case 2:
                    finalPrice=price*0.85;
                    break;
                case 3:
                   finalPrice= price*0.9;
                    break;

            }
        }


        return finalPrice;*/


        System.out.println("请输入机票原价");
        double price= scan.nextDouble();
        System.out.println("请输入月份");
        int month= scan.nextInt();
        System.out.println("请选择舱位： 1.头等舱 2.商务舱 3.经济舱");
        int num = scan.nextInt();
        double finalPrice=calAirPrice(price,month,num);
        if (finalPrice!=-1){
            System.out.println("最终价格为："+finalPrice);

        }

    }
    public static double calAirPrice(double price,int month,int num){
        double finalPrice=0.0;
        if (month<1&&month>12){
            System.out.println("输入错误");
            return -1;
        }
        if (num<1&&num>3){
            System.out.println("输入错误");
            return -1;
        }
        if (month<=10&&month>=5){
            switch (num){
                case 1:
                    finalPrice=price*0.7;
                    break;
                case 2:
                    finalPrice=price*0.8;
                    break;
                case 3:
                    finalPrice=price*0.9;
                    break;
            }
        }else{
            switch (num){
                case 1:
                    finalPrice=price*0.8;
                    break;
                case 2:
                    finalPrice=price*0.85;
                    break;
                case 3:
                    finalPrice=price*0.9;
                    break;

            }

        }



        return finalPrice;
    }
    }
